<template>
    <div> 
        <p>页面</p>
        <el-form :model="TagForm" :rules="rules" ref="TagForm" label-width="100px" class="demo-ruleForm">
  
            <el-form-item label="标签名" prop="name">
                <el-input v-model="TagForm.name"></el-input>
            </el-form-item>
            
        
            <el-form-item label="创建时间" prop="createTime">
            <el-col :span="11">
                <el-date-picker type="date" placeholder="选择日期" v-model="TagForm.createTime" style="width: 100%;"></el-date-picker>
            </el-col>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="submitForm('TagFrom')">确定</el-button>
                <el-button @click="resetForm('TagForm')">重置</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>
  
<script>
import { mapState} from 'vuex'
export default {
    data() {
        return {
            TagForm: {
                name: '',
                createTime:'',
            },
            rules: {
                name: [
                { required: true, message: '标签名', trigger: 'blur' },
                { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
                ],
                createTime: [
                { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
                ],
            }
        }
    },
    methods:{
        async submitForm(){
            if(this.title == "添加"){
                const res = await this.$axios.post("tag/AddTags",this.TagForm)
                console.log(res)
                if(res.code == "200"){
                    this.$router.push("/tags")
                    this.$message.success(res.msg)
                }
                else{
                    this.$message.error(res.msg)
                }
            }
            // else{
            //     const ase = await this.$axios.put("Song/UpdateSong",this.SongForm)
            //     console.log(ase)
            //     this.$router.push("/song")
            //     this.$message.success(ase.msg)
            // }
        },
          handlEditor(val){
          this.SongForm.lyric = val.replace(/<[^>]+>/g,"\n")
          },
          sendmusic(val){
              this.SongForm.url = val
          },
          resetForm(formName) {
          this.$refs[formName].resetFields();
          this.$refs.uploadimg.clear()
          this.$refs.wangedit.editor.clear()
          this.$refs.uploadmusic.clear()
        },
          sendimg(val){
          this.SongForm.image = val
          console.log(val)
          },
      },
      created(){
        // if(this.title == "编辑"){
        //   this.fileList.push({name:'',url:this.SongForm.image})
        //   this.$nextTick(()=>{
        //     this.$refs.wangedit.html=this.SongForm.lyric
        //   })
        //   this.fileList1.push({name:'',url:this.SongForm.url})
        // }
      },
      computed:{
        ...mapState('song1',['SingerId']),
        ...mapState('SongDatas',['title','SongData'])
      }
}
</script>
  
<style scoped>
   
</style>